package homework.homework1;

import javax.swing.*;
import java.awt.*;

public class MainJFrame extends JFrame {

    JPanel p1, p2, p3;

    public MainJFrame(){
        this.setSize(500, 500);
        this.setDefaultCloseOperation(3);
        this.setLocationRelativeTo(null);
        this.setLayout(null);

        MouseEvent me = new MouseEvent(this);

        p1 = new JPanel();
        p1.setBounds(50, 50, 50, 50);
        p1.setBackground(Color.red);
        p1.setBorder(BorderFactory.createLineBorder(Color.black));
        p1.addMouseListener(me);

        p2 = new JPanel();
        p2.setBounds(50, 150, 50, 50);
        p2.setBackground(Color.blue);
        p2.setBorder(BorderFactory.createLineBorder(Color.black));
        p2.addMouseListener(me);

        p3 = new JPanel();
        p3.setBounds(50, 250, 50, 50);
        p3.setBackground(Color.green);
        p3.setBorder(BorderFactory.createLineBorder(Color.black));
        p3.addMouseListener(me);

        this.add(p1);
        this.add(p2);
        this.add(p3);
        this.setVisible(true);
    }

    public static void main(String[] args){
        new MainJFrame();
    }
}
